---
title: "引用本地或私服上的maven插件"
date: 2019-10-7
categories:
- java
tags:
---

<div id="content">
<p>
即使在settings.xml中配置好了私服的地址，mvn compile命令也报找不到此插件的错误，
</p>
<blockquote>
<p>
<a href="https://stackoverflow.com/questions/34512824/how-do-i-include-a-maven-plugin-from-a-local-repository">https://stackoverflow.com/questions/34512824/how-do-i-include-a-maven-plugin-from-a-local-repository</a>
</p>
</blockquote>
<p>
If you mean local repository in the <a href="https://maven.apache.org/guides/introduction/introduction-to-repositories.html">classic sense</a>, make sure that you installed your plugin jar correctly. Install it to your local repository again with the following command:
</p>
<p>
mvn install:install-file -Dfile=/some/path/somePlugin.jar -DgroupId=someGroupId -DartifactId=somePlugin -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true
</p>
<p>
You should then be able to use your plugin in your Maven build.
</p>
<p>
If you mean local in the sense of some locally hosted repository, you need to specify the repository containing your artifact as a pluginRepository. Add the following to the top level of your pom.xml:
</p>
<p>
&lt;pluginRepositories&gt;
    &lt;pluginRepository&gt;
        &lt;id&gt;some-repo&lt;/id&gt;
        &lt;name&gt;Some Repository&lt;/name&gt;
        &lt;url&gt;<a href="http://some.host/some/path">http://some.host/some/path</a>&lt;/url&gt;
        &lt;releases&gt;
            &lt;enabled&gt;true&lt;/enabled&gt;
        &lt;/releases&gt;
        &lt;snapshots&gt;
            &lt;enabled&gt;true&lt;/enabled&gt;
        &lt;/snapshots&gt;
    &lt;/pluginRepository&gt;
&lt;/pluginRepositories&gt;
</p>
</div>
<div class="status" id="postamble">
<p class="date">Date: 2019-10-7</p>
<p class="author">Author: gdme1320</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
